package com.wenwan.manage.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wenwan.manage.service.UserWeiXinService;

import javax.annotation.Resource;

/**
 * 用户-绑定的微信小程序号
 * 
 * @author Admin
 *
 */
@Controller
@RequestMapping(value = "/user/wei/xin")
public class UserWeiXinController {

	@Autowired
	private UserWeiXinService userWeiXinService;

	@ResponseBody
	@RequestMapping(value = "/get/openid/by/code", method = { RequestMethod.GET })
	public Map<String, Object> getOpenIdByCode(@RequestParam(required = true) String code) {
		return userWeiXinService.getOpenIdByCode(code);
	}

	@ResponseBody
	@RequestMapping(value = "/create", method = { RequestMethod.POST })
	public Map<String, Object> createOrUpdate(@RequestParam(required = true) String openid,
			@RequestParam(required = true) String userId) {
		return userWeiXinService.create(openid, userId);
	}

}
